var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0}), (o.QiriHongbaoItem = void 0);
var a = t("Counter"),
    i = t("Platforms"),
    s = t("Sounds"),
    c = t("QiriHongbao"),
    l = t("ConfS"),
    u = cc._decorator,
    p = u.ccclass,
    f =
        (u.property,
        (function (t) {
            function e() {
                return (null !== t && t.apply(this, arguments)) || this;
            }
            return (
                n(e, t),
                (e.prototype.init = function (t) {
                    var e = this;
                    (this.time = this.node.getChildByName("time").getComponent(cc.Label)),
                        (this.lock_ = this.node.getChildByName("lock_")),
                        (this.yilingqu = this.node.getChildByName("yilingqu")),
                        (this.ling = this.node.getChildByName("ling")),
                        (this.视频 = this.ling.getChildByName("视频")),
                        (this.最高 = this.node.getChildByName("最高")),
                        (this.info = this.node.getChildByName("info").getComponent(cc.Label)),
                        (this.index = t),
                        this.node.on(cc.Node.EventType.TOUCH_END, function () {
                            s.Sounds.playFX("点击"),
                                e.ling.active
                                    ? i.default.platformCtrl.领取红包(function (t) {
                                          t
                                              ? i.default.platformCtrl.toast(t)
                                              : ((i.default.userStorage.上一个七日红包领取时间 = new Date().getTime()),
                                                i.default.userStorage.七日红包当天领取记录.push(1),
                                                i.default.userStorage.setDirty(),
                                                i.default.popups.getPopup(c.QiriHongbao).refresh(),
                                                i.default.七日红包按钮 && i.default.七日红包按钮.refresh(),
                                                i.default.platformCtrl.toast("红包已发放，请注意查收！"));
                                      })
                                    : e.time.node.active
                                    ? i.default.platformCtrl.toast("不是不能领，时候未到。")
                                    : e.yilingqu.active
                                    ? i.default.platformCtrl.toast("已领取过了！")
                                    : i.default.platformCtrl.toast("需先领取上个红包！");
                        });
                }),
                (e.prototype.refresh = function () {
                    var t = this;
                    if (
                        ((this.time.node.active = !1),
                        (this.lock_.active = !1),
                        (this.最高.active = !1),
                        (this.yilingqu.active = !1),
                        (this.ling.active = !1),
                        1 == c.QiriHongbao.第n天 && 0 == this.index ? (this.视频.active = !1) : (this.视频.active = !0),
                        this.counter && (this.counter.stop(), (this.counter = null)),
                        this.index < i.default.userStorage.七日红包当天领取记录.length)
                    )
                        (this.yilingqu.active = !0),
                            (this.info.string = l.DatasManager.七日红包金额[this.index] + "元");
                    else if (this.index == i.default.userStorage.七日红包当天领取记录.length) {
                        (this.最高.active = !0),
                            (this.info.string = +l.DatasManager.七日红包最高可得[this.index] + "元");
                        var e =
                            l.DatasManager.七日红包冷却时间[this.index] -
                            Math.ceil((new Date().getTime() - i.default.userStorage.上一个七日红包领取时间) / 1e3);
                        (this.time.node.active = !0),
                            e > 0
                                ? ((this.counter = new a.default()),
                                  this.counter.init(e, function (e) {
                                      (t.time.string = i.default.formatTime(e, !1, !1)),
                                          i.default.七日红包按钮 &&
                                              (i.default.七日红包按钮.time.string = t.time.string.replace(":", "："));
                                  }),
                                  this.counter.start(function () {
                                      (t.counter = null),
                                          (t.ling.active = !0),
                                          i.default.七日红包按钮 && i.default.七日红包按钮.refresh();
                                  }))
                                : ((this.time.string = "00:00"), (this.ling.active = !0));
                    } else
                        (this.lock_.active = !0),
                            (this.最高.active = !0),
                            (this.info.string = l.DatasManager.七日红包最高可得[this.index] + "元");
                }),
                (e = r([p], e))
            );
        })(cc.Component));
o.QiriHongbaoItem = f;
